/**
 *
 * User: rendong
 * Date: 12-9-3
 * Time: 下午10:49
 * $Id: GBitmap.js 12 2012-09-10 16:47:05Z rendong237@gmail.com $
 */

function GBitmap(){

}

GBitmap.extend(new GDisplayObject());


GBitmap.prototype.image = null;

GBitmap.prototype.setUrl = function(url)
{
    this.image = new GImage();

    var self = this;
    this.image.loadImage(url, function(){
        self.width = self.image.width;
        self.height = self.image.height;
    });
}

/**
 *
 * @param image {Image}
 */
GBitmap.prototype.setImage = function(image)
{
    if (image.finish == false)
        throw new Error("setImage image file not load complete!");

    this.image = image;
    this.width = image.width;
    this.height = image.height;
}

/**
 * 渲染图片
 * @param dirtyRect
 */
GBitmap.prototype.render = function(dirtyRect)
{
    if (this.image!= null && this.image.finish == true && this.visible && this.alpha > 0)
        this.stage.context.drawImage(this.image.image,this.x, this.y, this.width, this.height);
}